import { ApiBase, Route, src, resHtml, valid } from 'koacat'
import { App, Ctx } from '../../app'

export class DisplayApi extends ApiBase<App, Ctx> {
  constructor(app: App) {
    super(app)
    app.vite.include('inTime', src('/services/display/inTime.vue'))
    app.vite.include('trend', src('/services/display/trend.vue'))
    app.vite.include('tab', src('/services/display/tab.vue'))
    app.vite.include('group', src('/services/display/group.vue'))
    app.vite.include('goods', src('/services/display/goods.vue'))
  }

  public routes: Route<Ctx>[] = [{
    tags: ['view'],
    path: '/display/inTime',
    middlewares: [],
    get: async (ctx: Ctx) => resHtml(ctx, await this.app.vite.render('inTime', {}, '实时数据总览'))
  }, {
    tags: ['view'],
    path: '/display/trend',
    middlewares: [],
    get: async (ctx: Ctx) => resHtml(ctx, await this.app.vite.render('trend', {}, '趋势总览'))
  }, {
    tags: ['view'],
    path: '/display/tab',
    middlewares: [],
    get: async (ctx: Ctx) => resHtml(ctx, await this.app.vite.render('tab', {}, '用户标签管理'))
  }, {
    tags: ['view'],
    path: '/display/group',
    middlewares: [],
    get: async (ctx: Ctx) => resHtml(ctx, await this.app.vite.render('group', {}, '用户群组'))
  }, {
    tags: ['view'],
    path: '/display/goods',
    middlewares: [],
    get: async (ctx: Ctx) => resHtml(ctx, await this.app.vite.render('goods', {}, '商品动销'))
  }]
}
